package com.Al.pattern.lazy;

/**
 * @Author lizhigang Date: 2019/4/17 23:05
 * @description:实现内部类懒加载方式
 */
public class LazyInnerClassSingleton {
	private LazyInnerClassSingleton(){
		if (InnerClass.LAZY != null){
			throw new RuntimeException("不允许使用构造方法创建实例！");
		}
	};

	//利用jvm实现原理实现了线程安全同时未使用锁机制，最牛的懒汉式
	public static LazyInnerClassSingleton newInstence(){
		return InnerClass.LAZY;
	}
	private static class InnerClass{
		private static final LazyInnerClassSingleton LAZY = new LazyInnerClassSingleton();
	}
}
